<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>基金净值</title>
	<link rel="stylesheet" type="text/css" href="../../build/css/base.css"/>
	<link rel="stylesheet" type="text/css" href="../../build/css/style.css">
	<script src="../../build/js/jquery.min.js"></script>
</head>
<body>
	<div id="container" style="padding-bottom:10px;">
		<div class="history-value">
			<ul class="value-title  clear-fix">
				<li>日期</li>
				<li>单位净值</li>
				<li>累计净值</li>
				<li>日涨幅</li>
			</ul>
			<ul class="value-con clear-fix">
				<li class="clear-fix" v-for="item in valueList">
					<span>{{item.netValueDate | formatTime}}</span>
					<span>{{item.netValue}}</span>
					<span class="emptyHandle">{{item.accumulatedNet}}</span>
					<span v-if="item.riseDecline >= 0" class="plus">+{{item.riseDecline}}%</span>
					<span v-else class="negative">{{item.riseDecline}}%</span>
				</li>
			</ul>
		</div>
		<div class="empetDate">
			<span class="iconfont">&#xe602;</span>
			抱歉！没找到更多数据
		</div>
	</div>
<script src="../../build/public/vue.js" charset="utf-8"></script>
<script src="../../build/public/vue-resource.js" charset="utf-8"></script>
<script src="../../build/js/config.js" charset="utf-8"></script>
<script src="../../build/js/common.js" charset="utf-8"></script>

<script type="text/javascript">
var vm = new Vue({
	el:"#container",
	data:{
		idStr:'',
		page:1,
		valueList:[],
		pageCount:'',
	},
	mounted:function(){
		this.$nextTick(function(){
			vm.idStr = vm.getParameter('idStr');
			this.getList();
			refresh(this.refreshData());    //监听滚动到底部->触发refreshData()
		})
	},
	updated:function () {
		this.$nextTick(function(){
			vm.emptyHandle();
		});
	},
	methods:{
		//获取列表数据
		getList:function(){
			loader.init();
			get('/product/publicFund/fundnetvaluepage',{
				currentPage:vm.page,
				publicFundId:vm.idStr,
				startDay:'',
				endDay:'',
			},function(res){
				vm.pageCount = res.data.totalCount/res.data.pageSize;
				vm.valueList = vm.valueList.concat(res.data.resultList);
				if(res.data.resultList.length == 0){          //没请求到数据，判断为到底部
					refreshText('到底了哦！')
				}else{
					refreshText('上拉加载更多数据')
				}
				if(vm.valueList.length == 0){                   //总数据为空，判断为没有产品数据
					document.querySelector('.empetDate').style.display = 'block';
					refreshText('')
				}else{
					document.querySelector('.empetDate').style.display = 'none';
				}
				if(vm.valueList.length <5){                     //当次请求数据小于5,判断为没有下一页数据
					refreshText('')
				}
				loader.remove();
			})
		},
		changeColor:function(str){
			if(str>=0){
					return true;
				}else{
					return false;
				}
		},
		getParameter:function(name){    //获取链接中参数
			var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if(r!=null)return  unescape(r[2]); return null;
		},
		refreshData:function(){           //触发上拉加载后的回调
			return function(){
				if(vm.page > vm.pageCount){
					refreshText('到底了哦！')
				}else {
					vm.page++;
					vm.getList();
				}
			}
		},
		emptyHandle:function () {
			var contentLists = document.getElementsByClassName('emptyHandle');
			for(var i=0; i<contentLists.length;i++){
				console.log(contentLists[i].innerHTML);
				if(contentLists[i].innerHTML == ''){
					contentLists[i].innerHTML = '-- ';
				}   // if end
			}
		}
	}
})
</script>

</body>
</html>
